package cn.t.facade.order;


import cn.t.converter.order.ReconDetailDTOConverter;
import cn.t.core.facade.FacadeImpl;
import cn.t.core.mode.PageInfoDTO;
import cn.t.core.mode.PageQueryDTO;
import cn.t.dto.order.ReconDetailDTO;
import cn.t.model.order.ReconDetailDO;
import cn.t.request.ReconDetailReq;
import cn.t.service.order.ReconDetailService;
import cn.t.vo.order.ReconDetailVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 对账单明细表(ReconDetail)服务编排
 *
 * @author t
 * @since 2024-05-24 10:19:35
 */
@Slf4j
@Service
@AllArgsConstructor
public class ReconDetailFacade extends FacadeImpl<ReconDetailDTO, ReconDetailDO, ReconDetailDTOConverter, ReconDetailService> {

    public PageInfoDTO<ReconDetailVO> page(PageQueryDTO<ReconDetailReq> req) {
        ReconDetailDO queryParam = this.converter.req2Do(req.getParam());
        List<ReconDetailDO> list = this.service.findByModel(queryParam, req.getStart(), req.getPageSize(), "gmt_created", " desc");

        List<ReconDetailVO> recons = this.converter.do2Vo(list);

        long total = this.service.count(queryParam);

        return new PageInfoDTO<>(req.getPageNo(), req.getPageSize(), total, recons);
    }
}

